package com.sykj.springboot.common.utils;




import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * 功能描述: 线程池工具类
 *
 * @param:
 * @return:
 * @auther: 李旭辉
 * @date: 2019/3/20/020 13:36
 */
public class ThreadPoolUtils
{

    /**
     * CPU数量*2+4
     */
    public static final int CPU_NUMS = Runtime.getRuntime().availableProcessors() * 2 + 4;

    protected static final ThreadPoolExecutor fixedThreadPool;

    static {
        fixedThreadPool = new ThreadPoolExecutor(CPU_NUMS, CPU_NUMS, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>());

    }

    public static void execute(String logUUID,Runnable command) {
        fixedThreadPool.execute(command);
    }

    public static void execute(Runnable command) {
        fixedThreadPool.execute(command);
    }

    public static ThreadPoolExecutor getThreadPool(){
        return fixedThreadPool;
    }


}
